# -*- coding:utf-8 -*-
from database.db_handler import MysqlHander
from database.db_business import DbBusiness
from common.my_http import MyHttp
from common.my_baidu import MyBaidu
from common.my_time import MyTime
from common.macro_data import MacroData
from common.my_file import MyFile
import urllib.request
from bs4 import BeautifulSoup
from base_macro import MacroBase
import glob
import jieba
import re
import threading
import hashlib
import urllib.parse
import time
import os


'''
网络数据
'''


class BaiduNengyuan(MacroBase):
    def __init__(self, file_name):
        pass

    def __del__(self):
        pass
        
    
    def set_param(self):
        self.set_check_title(False)
        self.set_type(307)
        self.set_max_page(6) 
        self.set_forward(30)
    
    def do_query(self, word):
        self.set_param()
        print("do_query")
        diqu = self.business.query_gdp80()
        title_check_array = [word]
        for d in diqu:
            next_page = True
            words = [d, word]
            self.get_data([d, word], [[d],[word]], ["?",";","-"])
            
        


def nengyuan_api():
    d = BaiduNengyuan('./out/' + os.path.split(__file__)[-1].split(".")[0] + ".log")
    d.do_query("能源部")
    d.do_query("能源局")
    d.do_query("能源署")
    
    d.get_data(["国家能源局"], [["国家能源局"]], ["?",";","-"])
    d.get_data(["国际能源署"], [["国际能源署"]], ["?",";","-"])

if __name__ == '__main__':
    nengyuan_api()
